package CheckInputs;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class CheckInputs {

	@SuppressWarnings("deprecation")
	public static boolean Check7RangeDate(String inDate) {

		// public static boolean isValidDate {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		Date rightNow = Calendar.getInstance().getTime();
		Date inputedDate = new Date();
		Date hestoryDate = new Date();
		hestoryDate.setDate(rightNow.getDate());
		hestoryDate.setYear((hestoryDate.getYear() - 7));

		dateFormat.setLenient(false);
		try {

			inputedDate = dateFormat.parse(inDate.trim());
			if (inputedDate.after(rightNow) || inputedDate.before(hestoryDate)) {
				return false;
			}

		} catch (ParseException pe) {
			return false;
		}
		return true;
		// }

	}

	public static boolean CheckIsValidDate(String inDate) {

		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		dateFormat.setLenient(false);
		try {
			dateFormat.parse(inDate.trim());

		} catch (ParseException pe) {
			return false;
		}
		return true;

	}

	public static boolean CheckIfNumeirc(String str) {
		try {
			double d = Double.parseDouble(str);
		} catch (NumberFormatException nfe) {
			return false;
		}
		return true;
	}

	public static boolean CheckIfNoNumeirc(String str) {
		if (str.matches("[a-zA-Z]+$")) {
			return true;
		}
		return false;
	}
}
